import React, { Component } from "react";
import { Card, Icon, List } from "antd";
import { reqCategory } from "../../api";
import Category from "../category/category";
const Item = List.Item;

class ProuductDetail extends Component {
  constructor(props) {
    super(props);
    this.state = {
      cName1: "",
      cName2: "",
    };
  }
  async componentDidMount() {
    const { pCategoryId, categoryId } = this.props.location.state.product;
    if (pCategoryId == "0") {
      const result = await reqCategory(categoryId);
      const cName1 = result.data.name;
      this.setState({ cName1 });
    } else {
      const results = await Promise.all([
        reqCategory(pCategoryId),
        reqCategory(categoryId),
      ]);
      const cName1 = results[0].data.name;
      const cName2 = results[1].data.name;
      this.setState({
        cName1,
        cName2,
      });
    }
  }
  render() {
    const { name, desc, price, detail, imgs } =
      this.props.location.state.product;
    const title = (
      <span>
        <sapn onClick={() => this.props.history.goBack()}></sapn>
        <sapn>商品详情</sapn>
      </span>
    );
    return <>商品详情</>;
  }
}

export default ProuductDetail;
